<?php

namespace App\Http\Resources;

use App\Models\PmFormPlan;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class PmFormPlanResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  Request              $request
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'project_id' => $this->project_id,
            'project_name' => $this->project_name,  //TODO 需要项目模块完成后，填充此值
            'form_id' => $this->form_id,
            'form_title' => $this->form_title,
            'plan_status' => $this->plan_status,
            'plan_status_text' => PmFormPlan::$planStatusMapping[$this->plan_status] ?? '未知',
            'creator' => $this->creator,
            'creator_text' => $this->creator_text,
            'push_num' => 100,    //TODO 采集计划表中需要加一个字段，记录推送了多少条记录
            'submit_num' => 20,  //TODO 需要实时统计，其实也可以再表中加一个submit_num字段，当最后一个人提交时，更新此字段
            'created_at' => $this->created_at->toDateTimeString(),
            'updated_at' => $this->updated_at->toDateTimeString(),
        ];
    }
}
